package com.exercise.widgets.floatingbutton.dragfloatingactionbutton

import android.content.Context
import android.util.AttributeSet
import androidx.core.view.marginEnd
import androidx.core.view.marginLeft
import androidx.core.view.marginRight
import androidx.core.view.marginStart

/**
 * 默认实现的可拖拽,自动吸边的FloatingActionButton.
 * 默认配置吸边时的左右边距
 */
class DefaultDragFloatingActionButton @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : BaseDragFloatingActionButton(context, attrs, defStyleAttr) {
    override fun getDefaultLeftMargin(): Int {
        return if (marginStart > 0) {
            marginStart
        } else {
            marginLeft
        }
    }

    override fun getDefaultRightMargin(): Int {
        return if (marginEnd > 0) {
            marginEnd
        } else {
            marginRight
        }
    }
}